/*-----------------------------------------------------------------------------------
 *
 * 프로그램명	: HomePageDAO.java
 * Version		: 1.0
 * 작성일 		: 2006-08-16
 * 작성자		:
 * 수정일 		:
 * 수정자		:
 * 설명		 	:
 * 기능		 	:
 *
 * Copyright (c) 2000 by H&H  All Rights Reserved.
 *
-------------------------------------------------------------------------------------*/
package com.qbooks.home.store;

import java.io.*;

import java.util.*;
import java.sql.*;

import com.zll.framework.db.DBManager;
import com.zll.framework.model.HashBox;
import com.zll.framework.model.HashList;



public class StoreDAO
{
	public HashList selectMemberList(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/store.xml", "select_member_list", infos);
	}

	public HashList selectBookList(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/store.xml", "select_book_list", infos);
	}

	public HashList selectBookInfo(HashMap infos) throws Exception
	{
        return DBManager.executeQuery("/store.xml", "select_book_info", infos);
	}
	
	public HashList selectBookReviewList(HashMap param) throws Exception {
		return DBManager.executeQuery("/store.xml", "select_book_review_list", param);
	}
	
	public HashList selectBookReviewCount(HashMap param) throws Exception {
		return DBManager.executeQuery("/store.xml", "select_book_review_count", param);
	}
	
	public HashList selectCategoryInfo(HashMap infos) throws Exception {
        return DBManager.executeQuery("/store.xml", "select_category_info", infos);
	}
	
	
	public void insertBookReview(HashBox box) throws Exception
	{
		Connection conn = null;

        try
		{
			conn = DBManager.getConnection();

			DBManager.executeUpdate("/store.xml", "insert_book_review", box.getParam(), conn);
			DBManager.executeUpdate("/store.xml", "update_book_rate", box.getParam(), conn);
			
			conn.commit();
	    }
	    catch(Exception e)
	    {
	    	DBManager.rollback(conn);
	    	throw e;
		}
	    finally
	    {
	    	DBManager.closeConnection(conn);
		}
	}
	
	
	
	/**
	 * User 저장
	 *
	 * @param	infos
	 * @return	boolean
	 */
	public void purchaseBook(HashBox box) throws Exception
    {
		Connection conn = null;

        try
		{
			conn = DBManager.getConnection();


			DBManager.executeUpdate("/store.xml", "insert_sales", box.getParam(), conn);

			conn.commit();
	    }
	    catch(Exception e)
	    {
	    	DBManager.rollback(conn);
	    	throw e;
		}
	    finally
	    {
	    	DBManager.closeConnection(conn);
		}
    }


}
